package com.wzh.ojCommon.exception;


import com.wzh.ojCommon.common.ErrorCode;

/**
 * @Author wzh
 * @create 2023/4/1 20:31
 * @Description: 自定义异常类，根据构造方法构造异常
 * 当请求出现异常的时候通过Errorcode或者直接构建异常，在通过resultUtils返回对应结果
 */
public class BusinessException extends RuntimeException {

    private int code;

    public BusinessException(String message, int code) {
        super(message);
        this.code = code;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code=errorCode.getCode();
    }

    public BusinessException(ErrorCode errorCode,String message) {
        super(message);
        this.code=errorCode.getCode();
    }

    public int getCode() {
        return code;
    }
}
